# This is the main program. This can be changed quite a bit to
# customize it for your program... But remember what you do, so you
# can integrate with a new version of DSE when it comes out.

# Set up a default theme.
init python:
    
    register_stat("Physical", "physical", 0, 100)
    register_stat("Music", "music_skill", 0, 100)
    register_stat("Art", "art_skill", 0, 100)
    register_stat("Social", "social", 0, 100)

    dp_period("Morning", "morning_act")
    dp_choice("Archery", "archery")
    dp_choice("Music", "music_class")
    dp_choice("Hiking", "hiking")
    dp_choice("Canoeing", "canoeing", show = "day_of_week in [1,3,5]")
    dp_choice("Sailing","sailing", show = "day_of_week in [2,4]")
     

    dp_period("Afternoon", "afternoon_act")
    dp_choice("Swimming", "swimming")
    dp_choice("Arts and crafts", "arts")
    dp_choice("Stay in cabin", "stay_in")
    dp_choice("Horseback Riding","horseback", show = "day_of_week in [1,3,5]")
    dp_choice("Nature Studies","nature_studies", show = "day_of_week in [1,3,5]")
    dp_choice("Orienteering","orienteering", show = "day_of_week in [2,4]")
    
    dp_period("Evening", "evening_act")
    dp_choice("Campfire", "campfire")
    dp_choice("Stay in cabin", "stay_in")
    dp_choice("Go for a walk", "go_for_walk")
    
    #Special Events
    dp_choice("Ghost Stories", "special", show = "day == 3")
    dp_choice("Capture the Flag", "special", show = "day == 4")
    dp_choice("Night Swim", "special", show = "day == 6")
    dp_choice("Dance", "special", show = "day == 7")
    dp_choice("Square Dancing", "special", show = "day == 8")
    dp_choice("Trail Ride", "special", show = "day == 12")
    dp_choice("Canoe Trip", "special", show = "day == 13")
    dp_choice("Last Dance", "special", show = "day == 14")
     
init python:

    # Give us some space on the right side of the screen.
    style.window.right_padding = 100

    def toggle_skipping():
        config.skipping = not config.skipping

    show_button_game_menu = True

    def button_game_menu():

        if show_button_game_menu:

            # to save typing
            ccinc = renpy.curried_call_in_new_context

            ui.vbox(xpos=0.99, ypos=0.98, xanchor='right', yanchor='bottom')
            if config.skipping:
                ui.textbutton("Stop", clicked=toggle_skipping, xminimum=80)
            else:
                ui.textbutton("Skip", clicked=toggle_skipping, xminimum=80)
                
            ui.textbutton("Save", clicked=ccinc("_game_menu_save"), xminimum=80)
            ui.textbutton("Load", clicked=ccinc("_game_menu_load"), xminimum=80)
            ui.textbutton("Prefs", clicked=ccinc("_game_menu_preferences"), xminimum=80)
            ui.close()


    config.overlay_functions.append(button_game_menu)
    
# This is the entry point into the game.
label start:
    $ act = ""
    
    # Initialize the default values of some of the variables used in
    # the game.
    $ day = 0
    $ day_of_week = 0
    $ week = [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
    $ dayName = week[day_of_week]
    
    $ janice_affection = 0
    $ dale_affection = 0
    $ james_affection = 0
    $ chris_affection = 0
    

    # Show a default background.
    scene black

    # We jump to day to start the first day.
    jump intro


# This is the label that is jumped to at the start of a day.
label day:
    # Increment what day it is.
    $ day += 1
    $ day_of_week = (day + 5) % 7
    $ dayName = week[day_of_week]
    
    #end game
    if day >= 15:
        jump end_nothing

    scene black
    "It's day %(day)d. It is %(dayName)s."
    
label breakfast_time:

    # Set these variables to appropriate values, so they can be
    # picked up by the expression in the various events defined below. 
    $ period = "breakfast"
    $ act = "breakfast"

    # Ensure that the stats are in the proper range.
    $ normalize_stats()
    
    # Execute the events for the morning.
    call events_run_period

    # Here, we want to set up some of the default values for the
    # day planner. In a more complicated game, we would probably
    # want to add and remove choices from the dp_ variables
    # (especially dp_period_acts) to reflect the choices the
    # user has available to him.

    $ morning_act = None
    $ afternoon_act = None
    $ evening_act = None

    # Now, we call the day planner, which may set the act variables
    # to new values. We call it with a list of periods that we want
    # to compute the values for.
        
    call day_planner(["Morning", "Afternoon","Evening"])

    
    # We process each of the three periods of the day, in turn.
    
label morning:

    # Set these variables to appropriate values, so they can be
    # picked up by the expression in the various events defined below. 
    $ period = "morning"
    $ act = morning_act

    # Ensure that the stats are in the proper range.
    $ normalize_stats()
    
    # Execute the events for the morning.
    call events_run_period

    # That's it for the morning, so we fall through to the
    # afternoon.

label afternoon:

    # It's possible that we will be skipping the afternoon, if one
    # of the events in the morning jumped to skip_next_period. If
    # so, we should skip the afternoon.
    if check_skip_period():
        jump night

    # The rest of this is the same as for the morning.

    $ period = "afternoon"
    $ act = afternoon_act

    $ normalize_stats()
    
    call events_run_period
    
label dinner_time:

    # It's possible that we will be skipping the afternoon, if one
    # of the events in the morning jumped to skip_next_period. If
    # so, we should skip the afternoon.
    if check_skip_period():
        jump night

    # The rest of this is the same as for the morning.

    $ period = "dinner"
    $ act = "dinner"

    $ normalize_stats()
    
    call events_run_period

label evening:

    # It's possible that we will be skipping the afternoon, if one
    # of the events in the morning jumped to skip_next_period. If
    # so, we should skip the afternoon.
    if check_skip_period():
        jump night

    # The rest of this is the same as for the morning.

    $ period = "evening"
    $ act = evening_act

    $ normalize_stats()
    
    call events_run_period
    
label night:

    # This is now the end of the day, and not a period in which
    # events can be run. We put some boilerplate end-of-day text
    # in here.

    "That's all for today."

    # We call events_end_day to let it know that the day is done.
    call events_end_day

    # And we jump back to day to start the next day. This goes
    # on forever, until an event ends the game.
    jump day
         

# This is a callback that is called by the day planner. One of the
# uses of this is to show the statistics to the user.
label dp_callback:

    # Add in a line of dialogue asking the question that's on
    # everybody's mind.
    scene bg lodge
    
    $ t_mood = "normal"
    
    $ narrator("What should I do today?", interact=False)
    $ display_stats()

    return

